package com.fcat.common.user.service.impl;

import com.fcat.springboot.mybatis.service.impl.TsuantoneBaseServiceImpl;
import com.fcat.common.user.entity.RoleGroup;
import com.fcat.common.user.mapper.RoleGroupMapper;
import com.fcat.common.user.service.RoleGroupService;
import com.fcat.common.user.service.RoleService;
import com.fcat.common.user.vo.RoleGroupVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RoleGroupServiceImpl extends TsuantoneBaseServiceImpl<RoleGroupMapper, RoleGroup> implements RoleGroupService {

    @Autowired
    private RoleService roleService;

    @Override
    public List<RoleGroupVO> getTree(String roleName, String username, Long companyId) {
        List<Long> list = new ArrayList<>();
        list.add(companyId);
        Map<String, Object> map = new HashMap<>();
        map.put("username", username);
//        if (roleService.getUserIsAdmin(map)) list.add(Long.valueOf(0));
        map.put("roleName", roleName);
        map.put("companyId", companyId);
        return mapper.getTree(map);
    }

    @Override
    public List<RoleGroup> selectListByExample(Example example) {
        return mapper.selectByExample(example);
    }

    @Override
    public List<RoleGroup> getListByCompnayIdAndUsername(Map<String, Object> map) {
        return mapper.getListByCompnayIdAndUsername(map);
    }
}